package dayu.service.impl;

import dayu.vo.PasswordVo;
import org.apache.shiro.authc.credential.PasswordService;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author dayu
 * @create 2018/12/13 10:15
 * @Description
 */
@Service
public class PasswordServiceImpl implements PasswordService {

    //    String algorithmName, Object source, Object salt, int hashIterations
    @Value("${algorithmName}")
    private String algorithmName;

    @Value("${hashIterations}")
    private int hashIterations;

    @Override
    public String encryptPassword(Object passwordVo) throws IllegalArgumentException {
        PasswordVo vo= (PasswordVo) passwordVo;
        return new SimpleHash(algorithmName, vo.getPassword(), vo.getSalt(), hashIterations).toBase64();
    }

    @Override
    public boolean passwordsMatch(Object o, String s) {

        return false;
    }
}
